@use "../abstracts/mixins";

.jenkins-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: -2rem;
  overflow: hidden;

  &__list {
    display: flex;

    & > * {
      z-index: 1;
    }

    &-item {
      display: flex;
      align-items: center;

      a::before {
        content: "";
        position: absolute;
        inset: 0;
        pointer-events: all !important;
      }

      %breadcrumb-interactive-base {
        @include mixins.item($border: false);

        --item-background: transparent;

        display: flex;
        align-items: center;
        justify-content: center;
        height: 1.75rem;
      }

      & > a {
        @extend %breadcrumb-interactive-base;
      }

      .dropdown-indicator {
        @extend %breadcrumb-interactive-base;

        padding: 0 0.3125rem;
      }

      & > a,
      span {
        position: relative;
        font-size: var(--font-size-sm);
        font-weight: var(--font-bold-weight);
        margin: 0;
        padding: 0.25rem 0.5rem;
        color: inherit;
        text-decoration: none;
        text-wrap: nowrap;
        flex-shrink: 0;
        max-width: 25ch;
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow: hidden;
        display: inline-block;
      }

      // '/' separator between two items
      &::before {
        content: "/";
        position: relative;
        flex-shrink: 0;
        color: color-mix(in sRGB, var(--text-color-secondary) 30%, transparent);
        padding-left: 4px;
        padding-right: 4px;

        @media (prefers-contrast: more) {
          color: var(--text-color);
        }
      }
    }
  }
}

.jenkins-menu-dropdown-chevron {
  position: absolute;
  display: inline-block;
  width: 14px;
  height: 14px;
  right: 0;
  border: none;
  outline: none;
  cursor: pointer;
  padding: 0;
  transition: var(--standard-transition);
  background: transparent;
  top: 4px;

  &:hover {
    &::after {
      opacity: 1 !important;
    }
  }

  &:active {
    &::after {
      transform: translateY(2px);
      opacity: 0.5 !important;
    }
  }

  // Increase the hit target
  &::before {
    content: "";
    position: absolute;
    inset: -10px;
  }

  &::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    width: 14px;
    opacity: 0;
    transition: var(--standard-transition);
    background: var(--text-color);
    mask-image: url("../images/svgs/mask-breadcrumbs__after.svg");
    mask-position: center;
    mask-repeat: no-repeat;
  }
}

.model-link {
  position: relative;
  transition: var(--standard-transition) !important;
  margin-right: 40px !important;

  @media (hover: none) {
    &::before,
    &::after {
      right: -30px !important;
    }

    .jenkins-menu-dropdown-chevron {
      right: -22px;

      &::after {
        opacity: 1;
      }
    }
  }

  @media (hover: hover) {
    & + a.model-link {
      margin-left: 0 !important;
    }

    & + a.jenkins-table__badge {
      margin-left: -1.5rem !important;
    }

    &--open {
      &::before {
        background-color: var(--item-background--hover) !important;
        right: -30px !important;
      }
    }

    &--open,
    &:hover {
      & + a.jenkins-table__badge {
        margin-left: -1.5rem !important;
        transform: translateX(1.5rem);
      }

      &::before,
      &::after {
        right: -30px;
      }

      .jenkins-menu-dropdown-chevron {
        pointer-events: all;
        right: -22px;

        &::after {
          opacity: 0.5;
        }
      }
    }
  }
}

.model-link--float {
  z-index: 0;

  @media (hover: none) {
    margin-right: 30px !important;

    &::before,
    &::after {
      right: -30px !important;
    }

    .jenkins-menu-dropdown-chevron {
      right: -10px;

      &::after {
        opacity: 1;
      }
    }
  }

  @media (hover: hover) {
    margin-right: 0 !important;

    &::before,
    &::after {
      content: "";
      position: absolute;
      inset: -7px -10px;
      opacity: 0;
      border-radius: 6px;
      transition: var(--standard-transition);
    }

    &::before {
      z-index: -2;
      background: var(--background);
    }

    &::after {
      z-index: -1;
      background: var(--text-color);
    }

    &:hover {
      z-index: 10;

      @media (hover: hover) {
        &::before,
        &::after {
          right: calc((2ch + 14px) * -1);
        }
      }

      &::before {
        opacity: 1;
      }

      &::after {
        opacity: 0.15;
      }

      .jenkins-menu-dropdown-chevron {
        &::after {
          opacity: 0.5;
          display: none;
        }
      }
    }
  }
}
